// --------------------------------------------------------------------------------------------------------------------

// <copyright file="BaseTypeRequiredAttribute.cs" company="Social Development Spb">

//   Copyright (c) Social Development Spb 2009

// </copyright>

// <summary>

//   When applied to target attribute, specifies a requirement for any type which is marked with

//   target attribute to implement or inherit specific type or types.

// </summary>

// --------------------------------------------------------------------------------------------------------------------


using System;
using System.Collections.Generic;

namespace Diagnostics.Annotations
{
    #region Imported Namespaces

    

    #endregion


    /// <summary>
    /// When applied to target attribute, specifies a requirement for any type which is marked with 
    /// target attribute to implement or inherit specific type or types.
    /// </summary>
    /// <example>
    /// <code>
    /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
    /// public class ComponentAttribute : Attribute 
    /// {}
    /// [Component] // ComponentAttribute requires implementing IComponent interface
    /// public class MyComponent : IComponent
    /// {}
    /// </code>
    /// </example>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    [BaseTypeRequired(typeof(Attribute))]
    public sealed class BaseTypeRequiredAttribute : Attribute
    {
        #region Constants and Fields

        private readonly Type[] _baseTypes;

        #endregion


        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseTypeRequiredAttribute"/> class.
        /// </summary>
        /// <param name="baseTypes">The base types.</param>
        public BaseTypeRequiredAttribute(params Type[] baseTypes)
        {
            _baseTypes = baseTypes;
        }

        #endregion


        #region Properties

        /// <summary>
        /// Gets enumerations of specified base types.
        /// </summary>
        /// <value>The base types.</value>
        public IEnumerable<Type> BaseTypes
        {
            get
            {
                return _baseTypes;
            }
        }

        #endregion
    }
}